import { cdnBase } from '../config/index';
const imgPrefix = cdnBase;

const defaultDesc = [`${imgPrefix}/goods/details-1.png`];

const allGoods = [
  {
    saasId: '88888888',
    storeId: '1000',
    spuId: '0',
    title: '高拼装达模型强袭自由MGEX红异端独角兽白雪姬巴巴托斯拼装手办玩具',  //标题
    primaryImage: 'https://cdn-resource.xipin.top/mtg/mini-mall-gdjz/goods/01/p_1.jpg?x-image-process=image/resize,p_100',  //主图，列表页显示
    images: [
      'https://cdn-resource.xipin.top/mtg/mini-mall-gdjz/goods/01/p_1.jpg?x-image-process=image/resize,p_100',
    ],
    video: null,
    available: 1,
    minSalePrice: 6000,    //最低折扣价位
    minLinePrice: 6000,    //最低划线价位
    maxSalePrice: 6000,    //最高折扣价位
    maxLinePrice: 6800,    //最高划线价位
    spuStockQuantity: 60,    //库存
    soldNum: 10,             //已售数量
    isPutOnSale: 1,
    categoryIds: [
    ],
    specList: [
    ],
    skuList: [
    ],
    spuTagList: [],  //标签
    limitInfo: [
      {
        text: '限购2件',
      },
    ],  //限购信息
    desc: [
      'https://cdn-resource.xipin.top/mtg/mini-mall-gdjz/goods/01/d_1.jpg?x-image-process=image/resize,p_100',
      'https://cdn-resource.xipin.top/mtg/mini-mall-gdjz/goods/01/d_2.jpg?x-image-process=image/resize,p_100',
    ],    //商品详情图
    etitle: '',
  },
  {
    saasId: '88888888',
    storeId: '1000',
    spuId: '135686633',
    title: '高拼装达模型mg独角兽mb强袭自由金异端能天使pg机动战士手办玩具',
    primaryImage: 'https://cdn-resource.xipin.top/mtg/mini-mall-gdjz/goods/02/p_1.jpg?x-image-process=image/resize,p_100',
    minSalePrice: '6400',
    minLinePrice: '6400',
    maxSalePrice: '6400',
    maxLinePrice: '6900',
    isSoldOut: false,
    images: [
      'https://cdn-resource.xipin.top/mtg/mini-mall-gdjz/goods/02/p_1.jpg?x-image-process=image/resize,p_100',
    ],
    groupIdList: ['15029', '14023'],
    spuTagList: [],
    skuList: [
    ],
    isAvailable: 1,
    spuStockQuantity: 30,
    soldNum: 3,
    isPutOnSale: 1,
    specList: [
    ],
    promotionList: null,
    minProfitPrice: null,
    etitle: '',
    desc: [
      'https://cdn-resource.xipin.top/mtg/mini-mall-gdjz/goods/02/d_1.jpg?x-image-process=image/resize,p_100',
      'https://cdn-resource.xipin.top/mtg/mini-mall-gdjz/goods/02/d_2.jpg?x-image-process=image/resize,p_100',
    ],
  },
  {
    saasId: '88888888',
    storeId: '1000',
    spuId: '135691628',
    title: '高达模型MG朱雀MB强袭自由独角兽红异端一番赏合金色拼装手办玩具',
    primaryImage: 'https://cdn-resource.xipin.top/mtg/mini-mall-gdjz/goods/03/p_1.jpg?x-image-process=image/resize,p_100',
    images: [
      'https://cdn-resource.xipin.top/mtg/mini-mall-gdjz/goods/03/p_1.jpg?x-image-process=image/resize,p_100',
    ],
    minSalePrice: '6400',
    minLinePrice: '6400',
    maxSalePrice: '6400',
    maxLinePrice: '6900',
    isSoldOut: true,
    groupIdList: ['15029', '14023'],
    spuTagList: [],
    skuList: [
    ],
    isAvailable: 1,
    spuStockQuantity: 59,
    soldNum: 18,
    isPutOnSale: 1,
    specList: [
    ],
    promotionList: null,
    minProfitPrice: null,
    etitle: '',
    desc: [
      'https://cdn-resource.xipin.top/mtg/mini-mall-gdjz/goods/03/d_1.jpg?x-image-process=image/resize,p_100',
      'https://cdn-resource.xipin.top/mtg/mini-mall-gdjz/goods/03/d_2.jpg?x-image-process=image/resize,p_100',
    ],
  },
  {
    saasId: '88888888',
    storeId: '1000',
    spuId: '135686623',
    title: '高达模型MB菲尼克斯强袭自由MGEX红异端独角兽白雪姬拼装手办玩具',
    primaryImage: 'https://cdn-resource.xipin.top/mtg/mini-mall-gdjz/goods/04/p_1.jpg?x-image-process=image/resize,p_100',
    images: [
      'https://cdn-resource.xipin.top/mtg/mini-mall-gdjz/goods/04/p_1.jpg?x-image-process=image/resize,p_100',
    ],
    minSalePrice: '7500',
    minLinePrice: '7500',
    maxSalePrice: '7500',
    maxLinePrice: '7800',
    isSoldOut: false,
    groupIdList: [
    ],
    spuTagList: [],
    skuList: [
    ],
    isAvailable: 1,
    spuStockQuantity: 36,
    soldNum: 6,
    isPutOnSale: 1,
    desc: [
      'https://cdn-resource.xipin.top/mtg/mini-mall-gdjz/goods/04/d_1.jpg?x-image-process=image/resize,p_100',
      'https://cdn-resource.xipin.top/mtg/mini-mall-gdjz/goods/04/d_2.jpg?x-image-process=image/resize,p_100',
    ],
    specList: [
    ],
    promotionList: null,
    minProfitPrice: null,
    etitle: '',
  },
];

/**
 * @param {string} id
 * @param {number} [available] 库存, 默认1
 */
export function genGood(id, available = 1) {
  const specID = ['135681624', '135681628'];
  if (specID.indexOf(id) > -1) {
    return allGoods.filter((good) => good.spuId === id)[0];
  }
  const item = allGoods[id % allGoods.length];
  return {
    ...item,
    spuId: `${id}`,
    available: available,
    desc: item?.desc || defaultDesc,
    images: item?.images || [item?.primaryImage],
  };
}
